home *** CD-ROM | disk | FTP | other *** search
- /*** Instrumented for SRA TCAT-C instrumentor
- C instr: Release 6.1
- Fri Jun 15 08:01:41 1990
- C1 (segment) instrumentation
- UNIX Version, Release 6.1, 4/7/89
- ***/
- /* Copyright (c) 1988 by Software Research, Inc.
- All Rights Reserved.*/
- /*
- This program was instrumented by SR proprietary software,
- for use with the SR proprietary runtime package.
- Use of this program is limited by associated software license agreements.
- */
-
-
- /* SRA's Runtime Functions. */
-
-
- extern Strace();
- extern Ftrace();
- extern EntrMod();
- extern ExtMod();
- extern SegHit();
-
-
- /* TCATREST.C
- ** May 5, 1987
- ** Eduard Qualls
- **
- ** --example file for use with TCAT, STCAT, CapBak.
- */
-
-
- /*
- * @(#) stdio.h 1.4 87/06/22
- *
- * Copyright (C) The Santa Cruz Operation, 1985
- * This Module contains Proprietary Information of
- * The Santa Cruz Operation, Microsoft Corporation
- * and AT&T, and should be treated as Confidential.
- *
- */
-
- /*
- ** stdio.h
- */
-
-
-
-
- extern struct _iobuf {
-
- int _cnt;
- unsigned char *_ptr;
-
- unsigned char *_base;
- char _flag;
- char _file;
- } _iob[60];
-
-
- /* Buffer size for multi-character output to unbuffered files */
-
-
- /*
- * _IOLBF means that a file's output will be buffered line by line
- * In addition to being flags, _IONBF, _IOLBF and _IOFBF are possible
- * values for "type" in setvbuf.
- */
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- /*** getc -- get character from a stream.
- *
- * return character on success. return EOF on end of file or
- * error.
- *
- * int getc(stream)
- * FILE *stream;
- */
-
-
-
-
-
- /*** putc -- put character on a stream.
- *
- * return character on success. return EOF on error.
- *
- * int putc(ch, stream)
- * char ch;
- * FILE *stream;
- */
-
-
-
-
-
-
-
-
-
-
- extern struct _iobuf *fopen(), *fdopen(), *freopen(), *popen(), *
- tmpfile();
- extern char *fgets(), *gets(), *ctermid(), *cuserid();
- extern char *tempnam(), *tmpnam();
- extern void rewind(), setbuf();
- extern long ftell();
- extern unsigned char *_bufendtab[];
-
-
-
-
-
-
-
-
- /*
- * @(#) ctype.h 1.1 87/06/22
- *
- * Copyright (C) The Santa Cruz Operation, 1985
- * This Module contains Proprietary Information of
- * The Santa Cruz Operation, Microsoft Corporation
- * and AT&T, and should be treated as Confidential.
- *
- */
-
- /*
- ** ctype.h
- *
- * In order to get non-macro versions of toupper() and tolower(),
- * do a #undef. Non-macro versions are supplied in libc.
- *
- */
-
-
-
-
-
-
-
-
-
-
- extern char _ctype[];
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- char menu[13][79] = {
- "SOFTWARE RESEARCH'S RESTAURANT GUIDE \n",
- "\n",
- " What type of food would you like?\n",
- "\n",
- " 1 American 50s \n",
- " 2 Chinese - Hunan Style \n",
- " 3 Chinese - Seafood Oriented \n",
- " 4 Chinese - Conventional Style \n",
- " 5 Danish \n",
- " 6 French \n",
- " 7 Italian \n",
- " 8 Japanese \n",
- "\n\n"
- };
-
- int char_index;
-
- main(argc,argv) /* simple program to pick a restaurant, to demo TCAT */
- int argc;
- char *argv[];
- {
- int i, choice, c,answer;
- char str[79];
- int ask, repeat;
-
-
-
-
- int proc_input();
- Strace("IC",0x7504,&argc,&argv); EntrMod(27,"main",-1); SegHit(1);
-
-
- c = 3;
- repeat = 1;
-
- while(repeat){ SegHit(2); {
- printf("\n\n\n");
- for(i = 0; i < 13; i++){ SegHit(3);
- printf("%s", menu[i]);}; SegHit(4);
-
- gets(str);
- printf("\n");
- while(choice = proc_input(str)){ SegHit(5); {
- switch(choice) {
- case 1: SegHit(6);
- printf(
- "\tFog City Diner 1300 Battery 982-2000 \n");
- break;
- case 2: SegHit(7);
- printf(
- "\tHunan Village Restaurant 839 Kearney 956-7868 \n");
- break;
- case 3: SegHit(8);
- printf(
- "\tOcean Restaurant 726 Clement 221-3351 \n");
- break;
- case 4: SegHit(9);
- printf(
- "\tYet Wah 1829 Clement 387-8056 \n");
- break;
- case 5: SegHit(10);
- printf(
- "\tEiners Danish Restaurant 1901 Clement 386-9860 \n");
- break;
- case 6: SegHit(11);
- printf(
- "\tChateau Suzanne 1449 Lombard 771-9326 \n");
- break;
- case 7: SegHit(12);
- printf(
- "\tGrifone Ristorante 1609 Powell 397-8458 \n");
- break;
- case 8: SegHit(13);
- printf(
- "\tFlints Barbeque 4450 Shattuck, Oakland \n");
- break;
- default: SegHit(14);
- if(choice != -1){ SegHit(15);
- printf("\t>>> %d: not a valid choice.\n", choice);} else SegHit(16);
- break;
- }
- }}; SegHit(17);
- for(ask = 1; ask; ){ SegHit(18); {
- printf("\n\tDo you want to run it again? ");
- while((answer = ( --((&_iob[0]))->_cnt >= 0 ? (0xff & (int) (*((&
- _iob[0]))->
- _ptr++)) :
- _filbuf((&
- _iob[0])) )) != '\n'){ SegHit(19); {
- switch(answer) {
- case 'Y': SegHit(20);
- case 'y': SegHit(21);
- ask = 0;
- char_index = 0;
- break;
- case 'N': SegHit(22);
- case 'n': SegHit(23);
- ask = 0;
- repeat = 0;
- break;
- default: SegHit(24);
- break;
- }
- }}; SegHit(25);
- }}; SegHit(26);
- }}; SegHit(27); ExtMod("main");
- Ftrace(0);
- }
-
-
- int proc_input(in_str)
- char *in_str;
- {
- int tempresult = 0;
- char bad_str[80], *bad_input;
- int got_first = 0; EntrMod(24,"proc_input",-1); SegHit(1);
- bad_input = bad_str;
-
- while(((_ctype+1)[in_str[char_index]]&010)){ SegHit(2);
- char_index++;}; SegHit(3);
- for( ; char_index <= strlen(in_str); char_index++){ SegHit(4); {
- switch(in_str[char_index]) {
- case '0': SegHit(5);
- case '1': SegHit(6);
- case '2': SegHit(7);
- case '3': SegHit(8);
- case '4': SegHit(9);
- case '5': SegHit(10);
- case '6': SegHit(11);
- case '7': SegHit(12);
- case '8': SegHit(13);
- case '9': SegHit(14);
- /* process choice */
- tempresult = tempresult * 10 + (in_str[char_index] - '0');
- got_first = 1;
- break;
-
- default: SegHit(15);
- if(chk_char(in_str[char_index])){ SegHit(16); { ExtMod("proc_input");
- return(tempresult);
- }}
- else{ SegHit(17); {
- if(char_index > 0 && got_first){ SegHit(18);
- char_index--;} else SegHit(19);
- while(char_index <= strlen(in_str)){ SegHit(20); {
- if(chk_char(in_str[char_index])){ SegHit(21);
- break;}
- else{ SegHit(22);
- *bad_input++ = in_str[char_index];}
- char_index++;
- }}; SegHit(23);
- *bad_input = '\0';
- printf("\t>>> bad input: %s\n", bad_str);
- char_index++; ExtMod("proc_input");
- return(-1);
- }}
- }
- }}; SegHit(24); ExtMod("proc_input");
- return(0);
- }
-
- int chk_char(ch)
- char ch;
- { EntrMod(3,"chk_char",-1); SegHit(1);
- if(((_ctype+1)[ch]&010) || ch == '\0'){ SegHit(2); ExtMod("chk_char");
- return(1);}
- else{ SegHit(3); ExtMod("chk_char");
- return(0);}
- }
-